<?php

namespace App\Containers\AppSection\Qualification\Actions;

use App\Containers\AppSection\Log\Tasks\CreateLogTask;
use App\Containers\AppSection\Profile\Tasks\UpdateProfileTask;
use App\Containers\AppSection\Qualification\Tasks\UpdateQualificationTask;
use App\Ship\Parents\Actions\Action;
use App\Ship\Parents\Requests\Request;

class ReportQualificationAction extends Action
{
    public function run(Request $request)
    {
        app(UpdateQualificationTask::class)->run($request->profile()->qualification->id, [
            'unqualified_at' => now(),
            'status_key' => 'qualification_not_qualified',
        ]);

        app(UpdateProfileTask::class)->run($request->profile()->id, [
            'qualification_id' => null,
            'qualification_status_key' => 'qualification_not_qualified',
        ]);

        app(CreateLogTask::class)->run($request->profile()->id, 'Сообщение о несоответствии условиям квалифицированного инвестора', 'qualification');
    }
}
